package com.nexus.service.sys.service.mapstruct;

import com.nexus.core.service.mapstruct.TreeConverter;
import com.nexus.core.sys.dto.SysOfficeDTO;
import com.nexus.core.sys.entity.SysOffice;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

/**
 * SysOfficeWrapper
 *
 * @author 路正宁
 * @version 2023-03-15
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE, uses = {})
public interface SysOfficeWrapper extends TreeConverter<SysOffice, SysOfficeDTO> {

    SysOfficeWrapper INSTANCE = Mappers.getMapper(SysOfficeWrapper.class);

    @Mappings({
            @Mapping(source = "parent.id", target = "parent"),
            @Mapping(source = "org.id", target = "org"),
            @Mapping(source = "createBy.id", target = "createBy"),
            @Mapping(source = "updateBy.id", target = "updateBy")})
    SysOffice toEntity(SysOfficeDTO dto);

    @Mappings({
            @Mapping(source = "parent", target = "parent.id"),
            @Mapping(source = "org", target = "org.id"),
            @Mapping(source = "createBy", target = "createBy.id"),
            @Mapping(source = "updateBy", target = "updateBy.id")})
    SysOfficeDTO toDTO(SysOffice entity);

}

